package com.lingshu.app.network.interceptor;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * @author 于定金
 * @version 1.0
 * @Date 2024/4/18 17:17
 * @Description
 */
public class AuthInterceptor implements Interceptor {
    private String token;

    public AuthInterceptor(String token) {
        this.token = token;
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request originalRequest = chain.request();
        Request requestWithToken = originalRequest.newBuilder().header("Authorization", "Bearer " + token).method(originalRequest.method(), originalRequest.body()).build();
        return chain.proceed(requestWithToken);
    }
}
